home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Panorama / Panorama - Disk 19D (1987-07-22)(Pacific North-West Amigas Club)[WB].zip / Panorama - Disk 19D (1987-07-22)(Pacific North-West Amigas Club)[WB].adf / PipeHandler1.2 / pipe-handler.h < prev    next >
C/C++ Source or Header  |  1987-06-28  |  6KB  |  177 lines

  1. /****************************************************************************
  2. **  File:       pipe-handler.h
  3. **  Program:    pipe-handler - an AmigaDOS handler for named pipes
  4. **  Version:    1.2
  5. **  Author:     Ed Puckett      qix@mit-oz
  6. **
  7. **  Copyright 1987 by EpAc Software.  All Rights Reserved.
  8. **
  9. **  History:    05-Jan-87       Original Version (1.0)
  10. **        07-Feb-87    Added shared locks for individual pipes.
  11. **                PIPEDATA structure modified to include
  12. **                 a FileLock structure.
  13. **        07-Feb-87    Added #if's forautomatic pipe naming "feature"
  14. **                 for pipes specified with empty names.
  15. **        12-Feb-87    Added ParentDir packet handling.
  16. **        12-Feb-87    Fixed bug in OpenPipe() and PipeLock():
  17. **                 they previously ignored the lock passed in
  18. **                 packet.  Bug uncovered when pipes became
  19. **                 lockable, and thus assignable.
  20. **        26-Mar-87    Fixed bug in ClosePipe() in pipecreate.c: not
  21. **                 closing r/w mode properly (extraneous else).
  22. **        27-Mar-87    Added PipeDupLock() to pipedir.c and the case
  23. **                 for it in pipe-handler.c.  This was missing
  24. **                 in the original version!
  25. **        28-Mar-87    Added code to handler() to remove ':' from
  26. **                 end of handler name.  This caused problems
  27. **                 with Examine(); it expects no ending  ':'.
  28. */
  29.  
  30.  
  31.  
  32. /*---------------------------------------------------------------------------
  33. ** Compilation Flags
  34. ** -----------------
  35. ** DEBUG    : add code to open a window for debugging information.
  36. **        Messages are output as requests come in, etc.  DEBUG is
  37. **        active if defined at all.
  38. **
  39. ** (The following are active only if #defined nonzero)
  40. **
  41. ** CON_TAP_ONLY    : only CON: pipe taps are allowed.  The full CON:
  42. **         specification must be given, though, like CON:0/0/100/100/z.
  43. **
  44. ** PIPEDIR    : include code so that the handler looks like a directory.
  45. **        This allows "Dir" and "List" to work, as well as "CD".
  46. **        The functions in pipedir.c are unnecessary if false.
  47. **
  48. ** UPDATE_PIPEDATE : if PIPEDIR is true, then this controls whether or not
  49. **        the handler's date is updated with each access to a pipe,
  50. **        or is just left at its startup time.
  51. **
  52. ** AUTONAME    : include code so that specifying a null pipe name causes
  53. **        the handler to select a new, as yet unused, name.
  54. **        Unfortunately, this causes inconsistent behaviour for Lock(),
  55. **        since a null name indicates a lock is desired on the handler.
  56. **        Thus locking PIPE: and opening PIPE: reference different
  57. **        objects.
  58. */
  59.  
  60. #define   CON_TAP_ONLY      0
  61. #define   PIPEDIR           1
  62. #define   UPDATE_PIPEDATE   1
  63. #define   AUTONAME          0
  64.  
  65.  
  66.  
  67. #define   ALLOCMEM_FLAGS    MEMF_PUBLIC
  68.  
  69.  
  70.  
  71. /*---------------------------------------------------------------------------
  72. */
  73.  
  74. typedef struct pipedata
  75.   { PIPELISTNODE      link;                  /* for list handling */
  76.     char              name[PIPENAMELEN];     /* the pipe's name */
  77.     PIPEBUF           *buf;                  /* see pipebuf.c */
  78.     BYTE              flags;                 /* see values below */
  79.     PIPELISTHEADER    readerlist;            /* list of waiting read requests */
  80.     PIPELISTHEADER    writerlist;            /* list of waiting write requests */
  81.     BPTR              tapfh;                 /* file handle of tap, 0 if none */
  82. #if    PIPEDIR
  83.     ULONG             lockct;                /* number of extant locks */
  84.     struct FileLock   *lock;                 /* this pipe's lock - see note above */
  85.     struct DateStamp  accessdate;            /* date last accessed */
  86. #endif PIPEDIR
  87.   }
  88. PIPEDATA;
  89.  
  90. #define   OPEN_FOR_READ    (1 << 0)
  91. #define   OPEN_FOR_WRITE   (1 << 1)     /* flags for pipedata struct */
  92.  
  93.  
  94.  
  95. /*---------------------------------------------------------------------------
  96. ** PIPEKEYs are similar to file handles.  Each successful pipe open request
  97. ** has a PIPEKEY associated with it, which in turn refers to the pipe.
  98. ** The filehandle returned to the client has the address of the PIPEKEY
  99. ** stored in its Arg1 field, so that read, write and close packets will
  100. ** identify the pipe and its mode of opening.
  101. */
  102.  
  103. typedef struct pipekey
  104.   { PIPEDATA  *pipe;
  105.     int       openmode;     /* Type field of original open request */
  106.     IOTYPE    iotype;       /* (somewhat redundant) see pipesched.h */
  107.   }
  108. PIPEKEY;
  109.  
  110.  
  111.  
  112. extern struct DeviceNode  *DevNode;
  113. extern struct MsgPort     *PipePort;
  114. extern char               HandlerName[];
  115.  
  116. extern PIPELISTHEADER     pipelist;
  117.  
  118. extern PIPELISTHEADER     tapwaitlist;
  119. extern struct MsgPort     *TapReplyPort;
  120.  
  121. #if PIPEDIR
  122.   extern struct DateStamp  PipeDate;
  123. #endif PIPEDIR
  124.  
  125. #define   BPTRtoCptr(Bp)      ((char *) ((ULONG) (Bp) << 2))
  126. #define   CptrtoBPTR(Cp)      ((BPTR)   ((ULONG) (Cp) >> 2))
  127.  
  128. #define   ReplyPkt(pkt)       PutMsg ((pkt)->dp_Port, (pkt)->dp_Link)
  129.  
  130.  
  131. extern void      handler   ( /* StartPkt */ );
  132. extern PIPEDATA  *FindPipe ( /* name */ );
  133.  
  134.  
  135.  
  136. /*---------------------
  137. ** references to system
  138. */
  139.  
  140. extern struct Library     *OpenLibrary ();
  141. extern void               CloseLibrary ();
  142. extern struct Task        *FindTask ();
  143. extern struct MsgPort     *CreatePort ();
  144. extern ULONG              Wait ();
  145. extern struct Message     *GetMsg ();
  146. extern void               PutMsg ();
  147. extern BYTE               *AllocMem ();
  148. extern void               FreeMem ();
  149. extern void               CopyMem ();
  150.  
  151. extern struct MsgPort     *DeviceProc ();
  152. extern int                IoErr ();
  153.  
  154. #if PIPEDIR
  155.   extern struct DateStamp   *DateStamp ();
  156. #endif PIPEDIR
  157.  
  158. extern struct Library     *AbsExecBase;
  159.  
  160.  
  161.  
  162. /*---------------------------------
  163. ** these are new to the 1.2 release
  164. */
  165.  
  166. #ifndef MODE_READWRITE
  167. # define   MODE_READWRITE   1004
  168. #endif  MODE_READWRITE
  169.  
  170. #ifndef MODE_READONLY
  171. # define   MODE_READONLY    MODE_OLDFILE
  172. #endif  MODE_READONLY
  173.  
  174. #ifndef ACTION_END
  175. # define   ACTION_END       1007     /* not really new, just missing */
  176. #endif  ACTION_END
  177.